﻿//
// Created by xqyr on 2024/6/19.
//

#ifndef MQTTQT_MMQTT_H
#define MQTTQT_MMQTT_H

#include "qmqtt.h"
#include <QScopedPointer>
class Mmqtt :public  QObject{
Q_OBJECT
public:
    typedef enum{
    connected =1u,
    disconnected
}MQTTClientStatus;
public:
    Mmqtt(const QString& ip,uint port, QObject* parent = nullptr);
signals:
    void statusChanged(const MQTTClientStatus&);
    void subscribed(const QString& topic, const quint8 qos = 0);
    void received(const QMQTT::Message& message);
public:
    bool connectMqtt(const QString& ip = "",uint port = 0);
    bool subscribe(const QString& topic,const int id);
    bool publish(const QMQTT::Message&);
private:
    QScopedPointer<QMQTT::Client> client;
    MQTTClientStatus status;
};


#endif //MQTTQT_MMQTT_H
